package com.yc.home.cloudother.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.bean.Result;
import com.yc.entity.Createclass;
import com.yc.home.cloudother.mapper.CreateclassMapper;
import com.yc.home.cloudother.service.ICreateclassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lzk
 * @since 2024-10-05
 */
@Service
public class CreateclassServiceImpl extends ServiceImpl<CreateclassMapper, Createclass> implements ICreateclassService {

    @Autowired
    CreateclassMapper createclassMapper;

    @Override
    public Result opinionCode(String code) {
        LambdaQueryWrapper<Createclass> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Createclass::getNum, code);
        Createclass createclass = createclassMapper.selectOne(lqw);
        if(createclass == null){
            return new Result(0, "无效邀请码", null);
        }
        return new Result(1, "邀请码", createclass.getId().toString());
    }
}
